package com.nondo.dean.platform.controller.api.admin;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.nondo.dean.platform.model.result.AreaFindUserResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.nondo.dean.common.annotation.ApiVersion;
import com.nondo.dean.common.web.View;
import com.nondo.dean.platform.domain.Region;
import com.nondo.dean.platform.service.RegionService;

/**
 * @author xiaofan
 * @Description:
 * @throws
 * @date 2018-04-2311:22
 * @Version 0.1
 */
@RestController("apiAdminRegion")
@RequestMapping("/{v}/admin/region")
public class RegionController {

    @Autowired
    RegionService regionService;

    /**
     * 获取区域名称
     * @param regioCode
     * @return
     */
    @ApiVersion(1)
    @RequestMapping("/name")
    public View<String> getRegionName(@RequestBody String regioCode){
        View<String> view=new View<String>();
        view.setData(regionService.getRegionName(regioCode));
        return view;
    }

    /**
     * 获取客户区域列表
     * @param request
     * @param response
     * @return
     */
    @ApiVersion(1)
    @RequestMapping("/list")
    public View<List<Region>> search(HttpServletRequest request, HttpServletResponse response) {
        View<List<Region>> view = new View<List<Region>>(20000, "获取列表成功");

        List<Region> regionList = regionService.getRegionList();

        view.setData(regionList);

        return view;
    }

    /**
     * 查询区域下面对应的经销商
     * @param request
     * @param response
     * @return
     */
    @ApiVersion(1)
    @RequestMapping("/area/user/list")
    public View<List<AreaFindUserResult>> AreaFindUser(HttpServletRequest request, HttpServletResponse response,@RequestBody String ids) {
        View<List<AreaFindUserResult>> view = new View<List<AreaFindUserResult>>(20000, "获取列表成功");

        List<AreaFindUserResult> list = regionService.areaFindUser(new Integer[2]);

        view.setData(list);

        return view;
    }

}
